<template>
  <div class="detail">
    <HmHeader @clickLeft="$router.back()"></HmHeader>
    <hr />
    <div class="content">
      <h2>{{ obj.creator }}</h2>
      <div class="time">
        <span>{{ obj.createdAt }}</span>

        <span> | </span>
        <span>{{ obj.views }} 浏览量</span>
        <span> | </span>
        <span>{{ obj.likeCount }} 点赞数</span>
      </div>
      <div class="img">
        <img :src="obj.avatar" alt="" />
        <span>{{ obj.stem }}</span>
      </div>
      <div class="text">{{ obj.content }}</div>
    </div>
  </div>
</template>

<script>
import axios from "axios";
export default {
  data() {
    return {
      obj: {},
    };
  },
  created() {
    this.getDetail(this.$route.query.id);
  },
  methods: {
    async getDetail(id) {
      if (!id) return;
      const res = await axios({
        url: `http://interview-api-t.itheima.net/h5/interview/show?id=${id}`,
        headers: {
          Authorization: `Bearer ${localStorage.getItem("token")}`,
        },
      });
      //   console.log(res.data.data);
      this.obj = res.data.data;
    },
  },
};
</script>

<style lang="less" scoped>
.detail {
  padding: 0 10px;
  .img {
    margin: 20px 0;
    span {
      color: gray;
    }
  }
  .time {
    color: gray;
  }
}
</style>
